import React from "react";
import {Form,Input,Button, message} from 'antd'
import request from "@/utils/request";
import { useForm } from "rc-field-form";

function Addtag() {
   const [form] = Form.useForm()

  //  点击添加按钮
   const onFinish = (values) => {
   const  {lable,describe}=values
  //  console.log('Success:', values);
    request.post('/tag/add',{lable,describe}).then(({data})=>{
     if(data.code===200){
       message.success("添加成功")
     }
    })
  form.setFieldsValue({
    lable:"",
    describe:""
  })
  };

  return  <div style={{backgroundColor:'#fff',width:"70%",paddingTop:50,paddingBottom:20}}>
    <Form
       form={form}
      name="basic"
      labelCol={{
        span: 5,
      }}
      wrapperCol={{
        span: 16,
      }}
     
      onFinish={onFinish}
      // onFinishFailed={onFinishFailed}
      autoComplete="off"
    >
      <Form.Item
        label="标签"
        name="lable"
        rules={[
          {
            required: true,
            message: '请输入标签！',
          },
        ]}
      >
        <Input placeholder="请输入标签"/>
      </Form.Item>
       <Form.Item
        label="描述"
        name="describe"
        rules={[
          {
            required: true,
            message: '请输入描述!',
          },
        ]}
      >
        <Input placeholder="请输入简短的描述" />
      </Form.Item>

    
   

      <Form.Item
        wrapperCol={{
          offset: 5,
          span: 16,
        }}
      >
        <Button type="primary" htmlType="submit">
         添加
        </Button>
      </Form.Item>
    </Form>
  </div>
}
export default Addtag;
